package com.kaluli.project.service;

import java.sql.Timestamp;
import java.util.List;
import java.util.Set;

import javax.transaction.Transactional;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import com.kaluli.project.domain.entity.KllMainOrder;
import com.kaluli.project.domain.entity.KllMainOrderDetail;
import com.kaluli.project.domain.entity.KllMq;
import com.kaluli.project.domain.entity.KllUserFormVo;
import com.kaluli.project.domain.entity.KllWareHouse;
import com.kaluli.project.domain.repository.KllMainOrderDetailRepository;
import com.kaluli.project.domain.repository.KllMainOrderRepository;
import com.kaluli.project.domain.repository.KllUserDataRepository;
import com.kaluli.project.domain.repository.KllkolOrderRepository;

@Service
@Configuration
@Transactional
@PropertySource({"classpath:thridsystem.properties"})
public class KllKolOrderService {
	
	static Logger log = Logger.getLogger(KllKolOrderService.class);

	@Autowired
	private Environment env;

	@Autowired
	private KllMainOrderRepository kllMainOrderRepository;
	
	@Autowired
	private KllMainOrderDetailRepository kllMainOrderDetailRepository;
	
	@Autowired
	private KllMqService kllMqService;
	
	@Autowired
	private KllkolOrderRepository kllkolOrderRepository;
	
	@Autowired
	private KllUserDataRepository dataRepository;
	
	/**
	 * 更新达人收货状态
	 * 
	 * @param orderNumber
	 */
	public void updateKolOrder(String orderNumber){
		log.info("更新达人收货状态orderNumber="+orderNumber);
		if(StringUtils.isBlank(orderNumber)){
			return;
		}
		List<KllUserFormVo> list =dataRepository.findDarenOrder(orderNumber);
		if(list != null && list.size()>0){
			KllUserFormVo vo = list.get(0);
			if(vo.getCount()>0){
				//更新status=2;
				kllkolOrderRepository.updateKolOrder(orderNumber);
			}
		}
		
	}


	
	
	
}
